package wwk.common.http;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import android.content.Context;

public class HttpEngineManager
{
	List<HttpEngine> engineList;
	
	public HttpEngineManager()
	{
		engineList=new ArrayList<HttpEngine>(0);
	}
	
	public void cancelAll()
	{		
	    Iterator<HttpEngine> it=engineList.iterator();
		while(it.hasNext())
		{
			HttpEngine engine=it.next();
			engine.cancel();
		}
		engineList.clear();
	}
	
	public void removeUnrunning()
	{		
	    Iterator<HttpEngine> it=engineList.iterator();
		while(it.hasNext())
		{
			HttpEngine engine=it.next();
			if(!engine.isRunning())
			{
				it.remove();
			}
		}
	}
	
	public HttpEngine createHttpEngine(String url,HttpResponseInterface httpInterface,int tag)
	{
		HttpEngine engine=new HttpEngine(httpInterface,tag);
		engine.setUrl(url);
		engineList.add(engine);
		return engine;
	}
}
